<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/8
 * Time: 14:59
 */

namespace common\sources\write\peppercash;

use Yii;
use common\models\craftsman\PepperCashRecord;

class PepperCashAccess implements IPepperCashAccess
{
    public function addPepperCash($param)
    {
        return Yii::$app->db->createCommand()->insert('buy_pepper_cash_record', [
            'buy_id' =>  $param['buy_id'],
            'cash_num' => $param['cash_num'],
            'money' => $param['money'],
            'cash_money' => $param['cash_money'],
            'status' => $param['status'],
            'remark' => $param['remark'],
            'real_name' => $param['real_name'],
            "account_num" => $param['account_num'],
            'create_time' => time()
        ])->execute();
    }

    public function modifyPepperCash($data)
    {
        $sql = 'UPDATE ' . PepperCashRecord::tableName() . ' SET status = :status,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':status' => $data['status'],
                ':update_time' => time(),
                ':id' => $data['id']
            ])->execute();
    }
}